import type KoaRouter from '@koa/router';
import config from '../../config';

export enum ConfigApiPaths {
  Config = '/api/config',
}

const getAvailableSubApps = () => {
  return config.availableSubApps;
};

export const registerConfigApi = (router: KoaRouter) => {
  router.get(ConfigApiPaths.Config, (context) => {
    context.body = {
      availableSubApps: getAvailableSubApps(),
      env: config.getEnv(),
    };
  });
};
